<?php
class ModelDelimanChucnang extends Model 
{
	public function getList($where = "")
	{
		$query = $this->db->query("Select `dlm_chucnang`.* from `dlm_chucnang` where 1=1 ".$where);
		return $query->rows;
	}
	
	public function getItem($chucnangid)
	{
		$query = $this->db->query("Select * from `dlm_chucnang` where chucnangid = '".$chucnangid."'");
		return $query->row;
	}
		
	public function insert($data)
	{
		$chucnangid=$this->db->escape(@$data['chucnangid']);
		$machucnang=$this->db->escape(@$data['machucnang']);
		$tenchucnang=$this->db->escape(@$data['tenchucnang']);
				
		$field=array(
						'chucnangid',
						'machucnang',
						'tenchucnang'
					);
		$value=array(
						$chucnangid,
						$machucnang,
						$tenchucnang
					);
		return $this->db->insertData("dlm_chucnang",$field,$value);
	}
	
	public function update($data)
	{
		$chucnangid=$this->db->escape(@$data['chucnangid']);
		$machucnang=$this->db->escape(@$data['machucnang']);
		$tenchucnang=$this->db->escape(@$data['tenchucnang']);
				
		$field=array(
						'chucnangid',
						'machucnang',
						'tenchucnang'
					);
		$value=array(
						$chucnangid,
						$machucnang,
						$tenchucnang
					);
					
		$where="chucnangid = '".$chucnangid."'";
		$this->db->updateData("dlm_chucnang",$field,$value,$where);
	}	
			
	public function delete($chucnangid)
	{
		$chucnangid=$this->db->escape(@$chucnangid);
		$where="chucnangid = '".$chucnangid."'";
		$this->db->deleteData('dlm_chucnang',$where);
	}
	
	public function deletes($data)
	{
		foreach($data as $chucnangid)
		{
			$this->delete($chucnangid);
		}		
	}	
}

?>